<?php
/**
 * Created by PhpStorm
 * User: 龍zero
 * Date: 2022-04-10
 * Time: 16:28
 */
declare(strict_types=1);

namespace App\Request\Users;

use Hyperf\Validation\Request\FormRequest;

class LoginRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'username' => 'required|between:2,10',
            'password' => 'required|between:6,22',
        ];
    }
    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        return [
            'username.required' => '请输入用户名',
            'username.between' => '用户名必须在2-10个字符之间',
            'password.required'  => '请输入密码',
            'password.between'  => '密码长度必须在6-22个字符之间',
        ];
    }
}
